﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using BrokerBase.Lib.Person;

namespace Broker.View.Converter
{
    public class RadioSexConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string flg = parameter.ToString();

            SexType  st=(SexType)value;

            return (flg=="Male" && st==SexType.Male) || (flg=="FMale" && st==SexType.Fmale);
 
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool isCheck = (bool)value;

            string flg = parameter.ToString();

            SexType result=SexType.Male;

            if (flg == "Male" && isCheck)
                result = SexType.Male;
            else if(flg=="FMale" && isCheck)
                result=SexType.Fmale;

            return result;
        }
    }
}
